package kr.hkit.androidproject_caloriecheck;

import kr.hkit.androidproject_caloriecheck.diary.DiaryFragment;
import kr.hkit.androidproject_caloriecheck.exercise.ExerciseFragment;
import kr.hkit.androidproject_caloriecheck.food.FoodFragment;
import kr.hkit.androidproject_caloriecheck.home.HomeFragment;
import kr.hkit.androidproject_caloriecheck.settings.SettingFragment;
import android.app.ActionBar;
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;

public class MainActivity extends Activity{	
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		
		SharedPreferences pref = getSharedPreferences("user", 0);
		int height = pref.getInt("height", 0);
		
		if(height == 0){
			Intent intent = new Intent(MainActivity.this, IntroActivity.class);
			startActivity(intent);
			
		}
						
		ActionBar actionBar = getActionBar();
		actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
		
		ActionBar.Tab tab = actionBar.newTab();
		tab.setText("홈");
		HomeFragment frag = new HomeFragment();
		tab.setTabListener(new Tablistener(frag));
		actionBar.addTab(tab);
		
		ActionBar.Tab tab2 = actionBar.newTab();
		tab2.setText("음식");
		FoodFragment frag2 = new FoodFragment();
		tab2.setTabListener(new Tablistener(frag2));
		actionBar.addTab(tab2);
		
		ActionBar.Tab tab3 = actionBar.newTab();
		tab3.setText("운동");
		ExerciseFragment frag3 = new ExerciseFragment();
		tab3.setTabListener(new Tablistener(frag3));
		actionBar.addTab(tab3);
		
		ActionBar.Tab tab4 = actionBar.newTab();
		tab4.setText("달력");
		DiaryFragment frag4 = new DiaryFragment();
		tab4.setTabListener(new Tablistener(frag4));
		actionBar.addTab(tab4);
		
		ActionBar.Tab tab5 = actionBar.newTab();
		tab5.setText("설정");
		SettingFragment frag5 = new SettingFragment();
		tab5.setTabListener(new Tablistener(frag5));
		actionBar.addTab(tab5);
				
	}
}
